﻿using BarManager.Core.ApplicationService.Interfaces;
using BarManager.Core.BusinessRules.Interfaces.Validator;
using BarManager.Core.DomainModel;
using BarManager.Core.DomainService;
using BarManager.Core.Entity;
using System.Collections.Generic;

namespace BarManager.Core.ApplicationService
{
    public class MesaService : BaseApplicationService<Mesa>, IMesaService
    {            
        public MesaService(IObjectContext context,IMesaRepository repository, IMesaValidator validator)
            : base(context,repository, validator)
        {           
        }           

        //- Mesas que esten libres
        public IEnumerable<Mesa> GetAllMesasLibresByZona(int idZona)
        {
            return base.Find(x => x.ZonaId == idZona && x.Libre);
        }

        public void CambiarDisponibilidad(int id, bool disponible)
        {
            Mesa mesa = this.Get(x => x.Id == id);

            if (mesa != null)
            {
                mesa.Libre = disponible;
                this.Update(mesa);
            }
        }
    }
}
